package com.xcity.game.shop;

import com.alibaba.fastjson.annotation.JSONField;
import com.xcity.game.item.ItemTemplate;

import naga.x.App;
import naga.x.game.template.TemplateService;

/**
 * 商品信息
 * @author yang.li
 *
 */
public class Goods {

	@JSONField(serialize = false)
	protected ItemTemplate template;
	protected int id;
	protected int count;
	protected int price;
	
	public Goods(int id, int count, int price) {
		this.id = id;
		this.count = count;
		this.price = price;
	}

	public ItemTemplate getTemplate() {
		return template != null ? template : (template = App.getApp().getServiceManager().get(TemplateService.class).get(ItemTemplate.class, id));
	}

	public void setTemplate(ItemTemplate template) {
		this.template = template;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public int getPrice() {
		return price;
	}

	public void setPrice(int price) {
		this.price = price;
	}
	
	public String getName() {
		return getTemplate().getName();
	}
	
	public String getIcon() {
		return getTemplate().getIcon();
	}
	
	public String getDesc() {
		return getTemplate().getDesc();
	}
	
}
